import { CategoryTreeResult, CategoryTreeVo } from "@/api/category/types";

/**
 * 转换商品分类树形数据
 * @param data
 */
export function convertProductCateOptions(data: CategoryTreeResult) {
  const result: any[] = [];
  data.forEach((item: CategoryTreeVo) => {
    const temp: any = {
      value: item.id,
      label: item.name,
    };
    if (item.children) {
      temp.children = convertProductCateOptions(item.children);
    }
    result.push(temp);
  });
  return result;
}
